/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dp1.titandevelop.titano.view;

import dp1.titandevelop.titano.view.prod.ModulosT_PRO;
import dp1.titandevelop.titano.view.sec.ModulosT_SEG;
import dp1.titandevelop.titano.view.logist.ModulosT_LOG;
import dp1.titandevelop.titano.view.almac.ModulosT_ALM;
import dp1.titandevelop.titano.view.ventas.ModulosT_VEN;
import dp1.titandevelop.titano.view.admin.ModulosT_ADM;
import dp1.titandevelop.titano.persistent.PermisoXPerfil;
import dp1.titandevelop.titano.persistent.Usuario;
import dp1.titandevelop.titano.view.prod.ModulosT_PRO;
import java.util.List;
import javax.swing.JOptionPane;

/**
 *
 * @author chrestean
 */
public class ModulosT extends javax.swing.JFrame {

    /**
     * Creates new form TitanModulo
     */
    public ModulosT() {
        initComponents();
        this.setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        botonSeg = new javax.swing.JButton();
        botonLogistica = new javax.swing.JButton();
        botonAdmin = new javax.swing.JButton();
        botonProd = new javax.swing.JButton();
        botonVentas = new javax.swing.JButton();
        botonAlmacen = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Módulos Titano");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Escoja un módulo", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 1, 12))); // NOI18N

        botonSeg.setFont(new java.awt.Font("Calibri", 1, 11)); // NOI18N
        botonSeg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/seguridad.png"))); // NOI18N
        botonSeg.setText("SEGURIDAD");
        botonSeg.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonSegActionPerformed(evt);
            }
        });

        botonLogistica.setFont(new java.awt.Font("Calibri", 1, 11)); // NOI18N
        botonLogistica.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/compras.png"))); // NOI18N
        botonLogistica.setText("LOGISTICA");
        botonLogistica.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonLogisticaActionPerformed(evt);
            }
        });

        botonAdmin.setFont(new java.awt.Font("Calibri", 1, 11)); // NOI18N
        botonAdmin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/administracion.png"))); // NOI18N
        botonAdmin.setText("ADMINISTRACIÓN");
        botonAdmin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAdminActionPerformed(evt);
            }
        });

        botonProd.setFont(new java.awt.Font("Calibri", 1, 11)); // NOI18N
        botonProd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/produccion.png"))); // NOI18N
        botonProd.setText("PRODUCCIÓN");
        botonProd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonProdActionPerformed(evt);
            }
        });

        botonVentas.setFont(new java.awt.Font("Calibri", 1, 11)); // NOI18N
        botonVentas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/ventas.png"))); // NOI18N
        botonVentas.setText("VENTAS");
        botonVentas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonVentasActionPerformed(evt);
            }
        });

        botonAlmacen.setFont(new java.awt.Font("Calibri", 1, 11)); // NOI18N
        botonAlmacen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/almacen.png"))); // NOI18N
        botonAlmacen.setText("ALMACÉN");
        botonAlmacen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAlmacenActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(botonVentas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(botonLogistica, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(botonAdmin)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(botonAlmacen, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(botonProd, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(botonSeg, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, 0))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botonAdmin)
                    .addComponent(botonAlmacen))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botonLogistica)
                    .addComponent(botonProd))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botonVentas)
                    .addComponent(botonSeg))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(0, 0, 0))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botonSegActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonSegActionPerformed
        //ID Permiso 6
        //NO MODIFICAR !!!!!!!!!
      
        Integer i = 0;
        for (; i < LoginT.permisosxperfil.size(); i++) {
            if (6 == (Integer)LoginT.idspermisosxperfil.get(i)) {
                ModulosT_SEG frameSeguridad = new ModulosT_SEG();
                frameSeguridad.setVisible(true);
                break;
            }
        }
         if (i >= LoginT.permisosxperfil.size()) {
                JOptionPane.showMessageDialog(this, "No puedes proceder, al parecer careces de permisos.",
                        "No posee permisos",
                        JOptionPane.WARNING_MESSAGE);
            }

    }//GEN-LAST:event_botonSegActionPerformed

    private void botonAlmacenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAlmacenActionPerformed
        //ID Permiso 4
        //NO MODIFICAR !!!!!!!!!
     
        Integer i = 0;
        for (; i < LoginT.permisosxperfil.size(); i++) {
            
            if (4 == (Integer)LoginT.idspermisosxperfil.get(i)) {
                ModulosT_ALM frameAlmacen = new ModulosT_ALM();
                frameAlmacen.setVisible(true);
                break;
            }
        }
         if (i >= LoginT.permisosxperfil.size()) {
                JOptionPane.showMessageDialog(this, "No puedes proceder, al parecer careces de permisos.",
                        "No posee permisos",
                        JOptionPane.WARNING_MESSAGE);
            }


    }//GEN-LAST:event_botonAlmacenActionPerformed

    private void botonAdminActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAdminActionPerformed
        //ID Permiso 1
         //NO MODIFICAR !!!!!!!!!
    
        Integer i = 0;
           
        for (; i < LoginT.permisosxperfil.size(); i++) {
            if (1 == (Integer)LoginT.idspermisosxperfil.get(i)) {
                ModulosT_ADM frameAdm = new ModulosT_ADM();
                frameAdm.setVisible(true);
                break;
            }   
        }
        if (i >= LoginT.permisosxperfil.size()) {
                JOptionPane.showMessageDialog(this, "No puedes proceder, al parecer careces de permisos.",
                        "No posee permisos",
                        JOptionPane.WARNING_MESSAGE);
            }

    }//GEN-LAST:event_botonAdminActionPerformed

    private void botonVentasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonVentasActionPerformed
        //ID Permiso 3
        //NO MODIFICAR !!!!!!!!!
        Integer i = 0;
        for (; i < LoginT.permisosxperfil.size(); i++) {
            if (3 == (Integer)LoginT.idspermisosxperfil.get(i)) {
                ModulosT_VEN frameVentas = new ModulosT_VEN();
                frameVentas.setVisible(true);
                break;
            }
        }
         if (i >= LoginT.permisosxperfil.size()) {
                JOptionPane.showMessageDialog(this, "No puedes proceder, al parecer careces de permisos.",
                        "No posee permisos",
                        JOptionPane.WARNING_MESSAGE);
            }

    }//GEN-LAST:event_botonVentasActionPerformed

    private void botonLogisticaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonLogisticaActionPerformed
         //ID Permiso 2

        Integer i = 0;
                
        for (; i < LoginT.permisosxperfil.size(); i++) {
            if (2 == (Integer)LoginT.idspermisosxperfil.get(i)) {
                ModulosT_LOG frameLog = new ModulosT_LOG();
                frameLog.setVisible(true);
                break;
            }
        }
         if (i >= LoginT.permisosxperfil.size()) {
                JOptionPane.showMessageDialog(this, "No puedes proceder, al parecer careces de permisos.",
                        "No posee permisos",
                        JOptionPane.WARNING_MESSAGE);
            }

    }//GEN-LAST:event_botonLogisticaActionPerformed

    private void botonProdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonProdActionPerformed
         //ID Permiso 5

    
        Integer i = 0;
        for (; i < LoginT.permisosxperfil.size(); i++) {
            if (5 == (Integer)LoginT.idspermisosxperfil.get(i)) {
                ModulosT_PRO frameProduccion = new ModulosT_PRO();
                frameProduccion.setVisible(true);
                break;
            }
        }
        if (i >= LoginT.permisosxperfil.size()) {
                JOptionPane.showMessageDialog(this, "No puedes proceder, al parecer careces de permisos.",
                        "No posee permisos",
                        JOptionPane.WARNING_MESSAGE);
            }  
        
        
    }//GEN-LAST:event_botonProdActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ModulosT.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ModulosT.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ModulosT.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ModulosT.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ModulosT().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botonAdmin;
    private javax.swing.JButton botonAlmacen;
    private javax.swing.JButton botonLogistica;
    private javax.swing.JButton botonProd;
    private javax.swing.JButton botonSeg;
    private javax.swing.JButton botonVentas;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
}
